#!/bin/sh

# Redirect output to stderr.
exec 1>&2

# Activate the virtual environment
. venv/bin/activate

export SKIP_HEAVY_TESTS=1

# Run unused imports and variables check
if ! python3 -m autoflake --remove-all-unused-imports -r . --exclude venv,archived_code -c --quiet
then 
    echo "Unused imports and variables check failed"
    exit 1
fi

# Run formatting check
if ! python3 -m black --check . 
then 
    echo "Black formatting check failed"
    exit 1
fi

# Run tests
if ! python3 -m unittest
then
    echo "Tests failed"
    exit 1
fi

echo "All checks passed"